import logging
from Determining_ad.src.Tools.testing_tools import TestingUtils
import uuid

"""
自动化-OPPO（带平铺功能）
"""


class TestOppoCases111:
    # 定义全局变量
    all_df = None
    ad_df = None
    entity = None
    video_df = None
    first_df = None
    second_df = None
    quit_df = None
    quit_second_df = None

    def test1111(self, custom_error):
        # TestingUtils.get_ad_sum(custom_error, 5, '01', self.first_df, self.second_df)

        # # 激励视频事件是否正确
        # TestingUtils.video_event_true(custom_error, '53', self.video_df)
        #
        # TestingUtils.ad111_event_true(custom_error, '01', self.first_df, self.second_df)
        #
        # TestingUtils.img_num_result(custom_error, 1, 'ugdtimg', '01', self.first_df, self.second_df)
        #
        # TestingUtils.button_event_result(custom_error, '401', self.first_df)

        # TestingUtils.video_num_result(custom_error, self.video_df, 1, '52')
        #
        # TestingUtils.click_event_result(custom_error, '401', '01', self.first_df)

        # TestingUtils.no_first_ad(custom_error, return_Df, self.ad_df, self.all_df, '01', 'toutiao', '401')
        #
        # TestingUtils.video_num_result(custom_error, self.video_df, 0, '53')

        # # 点击退出弹窗
        # TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '401', self.entity, '1')
        #
        # # onhide
        # TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '402', self.entity, '2')

        # 退出弹窗上限
        TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '401', self.entity, '4')

        # onhead上限
        TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '402', self.entity, '3')

        # 给错误列表置空，并且报错
        custom_error.errors_nums()


class TestOppoCases1:
    # 定义全局变量
    all_df = None
    ad_df = None
    entity = None
    video_df = None
    first_df = None
    second_df = None
    quit_df = None
    quit_second_df = None

    def test_oppo_case_1(self, custom_error):
        # 激励视频是否正确
        TestingUtils.video_event_true(custom_error, '53', self.video_df)

        # 判断广告位的个数
        TestingUtils.get_ad_sum(custom_error, 5, '01', self.first_df, self.second_df)

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '01', self.first_df, self.second_df, 4)

        # 判读某屏某广告源个数是否正确
        TestingUtils.img_num_result(custom_error, 1, 'toutiao', '01', self.first_df, self.second_df)

        # 给错误列表置空，并且报错
        custom_error.errors_nums()

    def test_oppo_case_2(self, custom_error):
        # 判断广告位的个数
        TestingUtils.get_ad_sum(custom_error, 5, '02', self.first_df, self.second_df)

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '02', self.first_df, self.second_df, 4)

        # 判读某屏广告源个数是否正确
        TestingUtils.img_num_result(custom_error, 0, 'heytapimage', '02', self.first_df, self.second_df)

        # adbutton生效
        TestingUtils.button_event_result(custom_error, '402', '02', df_111=self.first_df)

        # 激励视频事件是否正确
        TestingUtils.video_event_true(custom_error, '51', self.video_df)

        # 给错误列表置空，并且报错
        custom_error.errors_nums()

    def test_oppo_case_3(self, custom_error):
        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '03', self.first_df, self.second_df, 4)

        # 激励视频事件是否正确
        TestingUtils.video_event_true(custom_error, '52', self.video_df)

        # 给错误列表置空，并且报错
        custom_error.errors_nums()

    def test_oppo_case_4(self, custom_error):
        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '04', self.first_df, self.second_df, 4)

        # adbutton是否上报
        TestingUtils.button_event_result(custom_error, '231', '04', df_110=self.second_df)

        # 激励视频是否上限
        TestingUtils.video_num_result(custom_error, self.video_df, 1, '51')

        # 给错误列表置空，并且报错
        custom_error.errors_nums()

    def test_oppo_case_5(self, custom_error):
        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '05', self.first_df, self.second_df, 4)

        # 激励视频是否上限
        TestingUtils.video_num_result(custom_error, self.video_df, 1, '52')

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '06', self.first_df, self.second_df, 4)

        # adbutton是否上报
        TestingUtils.button_event_result(custom_error, '241', '06', df_110=self.quit_df)

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '07', self.first_df, self.second_df, 4)

        # adbutton是否上报
        TestingUtils.button_event_result(custom_error, '232', '07', df_110=self.quit_df)

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '08', self.first_df, self.second_df, 4)

        # adbutton是否上报
        TestingUtils.button_event_result(custom_error, '233', '08', df_110=self.quit_df)

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '09', self.first_df, self.second_df, 4)

        # 判断广告位的个数
        TestingUtils.get_ad_sum(custom_error, 3, '09', self.first_df, self.second_df)

        # 给错误列表置空，并且报错
        custom_error.errors_nums()


class TestOppoCases2:
    # 定义全局变量
    all_df = None
    ad_df = None
    entity = None
    video_df = None
    first_df = None
    second_df = None
    quit_df = None
    quit_second_df = None

    def test_oppo_case_1(self, custom_error):
        # 判断激励视频个数
        TestingUtils.video_num_result(custom_error, self.video_df, 0, '53')

        # 广告事件是否正确
        TestingUtils.ad111_event_true(custom_error, '01', self.first_df, self.second_df, 0)

        # 第一屏个数
        TestingUtils.get_ad_sum(custom_error, 1, '01', self.first_df, self.second_df)

        # 判断nofirst情况
        TestingUtils.no_first_ad(custom_error, self.first_df, self.ad_df, self.all_df, '01', 'toutiao', '401')

        # 第二屏广告正确
        TestingUtils.ad111_event_true(custom_error, '02', self.first_df, self.second_df, 0)

        # 给错误列表置空，并且报错
        custom_error.errors_nums()

    def test_oppo_case_2(self, custom_error):
        # 退出弹窗广告是否正确
        TestingUtils.ad110_event_true(custom_error, self.quit_df, self.quit_second_df)

        # 231的点击button事件是否正确
        # oppo未加密的退出弹窗是231、232...
        TestingUtils.button_event_result(custom_error, '231', '01', df_110=self.quit_df)

        # 111广告事件正确
        TestingUtils.ad111_event_true(custom_error, '03', self.first_df, self.second_df, 0)

        # 点击231后apl是否正确
        TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '231', self.entity, '1')

        # hide后apl正确
        TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '403', self.entity, '2')

        # 111广告事件正确
        TestingUtils.ad111_event_true(custom_error, '04', self.first_df, self.second_df, 0)

        # 111广告个数为0
        TestingUtils.get_ad_sum(custom_error, 0, '05', self.first_df, self.second_df)

        # hide后apl限制正确
        TestingUtils.apl_result(custom_error, self.all_df, self.ad_df, '405', self.entity, '3')

        # 给错误列表置空，并且报错
        custom_error.errors_nums()


class TestOppoCases3:
    """
    无平铺功能
    """
    # 定义全局变量
    all_df = None
    ad_df = None
    entity = None
    video_df = None
    first_df = None
    second_df = None
    quit_df = None
    quit_second_df = None

    def test_oppo_case_1(self, custom_error):
        """
        991只开百度
        :param custom_error:
        :return:
        """
        # 判断111广告个数
        TestingUtils.get_ad_sum(custom_error, 3, '01', self.first_df, self.second_df)

        # 401点击正常
        TestingUtils.click_event_result(custom_error, '401', '01', self.first_df)

        #  点击百度后跳转倒落地页的埋点  这个估计判断不了

        # 111广告事件正确
        TestingUtils.ad111_event_true(custom_error, '02', self.first_df, self.second_df, 2)

        # 百度请求个数限制判断
        TestingUtils.bqt_num(custom_error, self.ad_df)

        # 给错误列表置空，并且报错
        custom_error.errors_nums()
